/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MyPartitioner.java
 *
 * Created on Jul 10, 2010, 7:35:44 PM
 */

package homomorphism;

import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.mapred.Partitioner;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import utility.LongPair;

/**
 *
 * @author takeshi
 */
public class SecondPartitioner
        implements Partitioner<LongPair,LongPair> {

    private JobConf conf;

    public void configure(JobConf conf) {
        this.conf = conf;
        initPartitioner();
    }

    private void initPartitioner() {
        // TODO any initialization goes here
    }

    @Override
    public int getPartition(LongPair key, LongPair value, int numReduceTasks) {
        // TODO return a partition in [0, numReduceTasks)
       return  (int) ( key.getFirst() * 127) % numReduceTasks;
        // return key.hashCode() % numReduceTasks;
    }
}
